keyerror when adding key in dict